package com.example.entity;

import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 购买记录实体类
 */
@Data
public class PurchaseRecord {
    
    /**
     * 购买记录ID
     */
    private Long id;
    
    /**
     * 用户ID
     */
    private Long userId;
    
    /**
     * 商品ID
     */
    private Long productId;
    
    /**
     * 商品名称
     */
    private String productName;
    
    /**
     * 商品编号
     */
    private String productCode;
    
    /**
     * 购买数量
     */
    private Integer purchaseQuantity;
    
    /**
     * 单价
     */
    private BigDecimal unitPrice;
    
    /**
     * 总金额
     */
    private BigDecimal totalAmount;
    
    /**
     * 购买状态：1-已完成，2-已取消
     */
    private Integer purchaseStatus;
    
    /**
     * 备注
     */
    private String remark;
    
    /**
     * 创建时间
     */
    private LocalDateTime createTime;
    
    /**
     * 更新时间
     */
    private LocalDateTime updateTime;
    
    /**
     * 删除标记：0-未删除，1-已删除
     */
    private Integer deleted;
    
    // 便捷方法
    public boolean isCompleted() {
        return this.purchaseStatus != null && this.purchaseStatus == 1;
    }
    
    public boolean isCancelled() {
        return this.purchaseStatus != null && this.purchaseStatus == 2;
    }
    
    public String getPurchaseStatusName() {
        if (purchaseStatus == null) {
            return "未知";
        }
        switch (purchaseStatus) {
            case 1:
                return "已完成";
            case 2:
                return "已取消";
            default:
                return "未知";
        }
    }
} 